package com.bdqn.config;


import jakarta.servlet.http.HttpServletRequest;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(UnauthorizedException.class)
    public ModelAndView unauthorizedExceptionHandler(UnauthorizedException e, HttpServletRequest request) {
        ModelAndView mv=new ModelAndView("403");
        mv.addObject("exception",e);
        mv.addObject("url",request.getRequestURL());
        return mv;
    }
}
